/*public class Node {
    public Node next;
    public Object data;
    public Node(Object data,Node next){
        this.data=data;
        this.next=next;
    }
}*/
public class Node<T> {
    public  T data;//数据域，保存数据元素
    public Node<T> next;//地址域，引用后续结点
    public Node(T data,Node<T> next )//构造结点，data指定数据元素，next指定后续结点
    {
        this.data = data;
        this.next = next;
    }
    public Node(){
        this(null,null);
    }
    //返回结点元素值对应的字符串

    @Override
    public String toString() {
        return this.data.toString();
    }
    //比较两个结点值是否相等，覆盖Object类的equals(obj)方法

    @Override
    public boolean equals(Object obj) {
        return obj == this || obj instanceof Node && this.data.equals(((Node<T>) obj).data) ;
    }
}


